//
//  MyRatingDetailVC.m
//  test
//
//  Created by 朱圳 on 2018/3/14.
//  Copyright © 2018年 朱圳. All rights reserved.
//

#import "MyRatingDetailVC.h"
#import "QuestionsModel.h"

@interface MyRatingDetailVC ()<UITableViewDelegate,UITableViewDataSource>
@property(strong,nonatomic)NSArray*list;
@property(nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSMutableArray *questionArray;
@end

@implementation MyRatingDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.tableView];
    [self requestData];
    self.xlTableView.dataSource = self;
    self.xlTableView.delegate = self;
    self.xlTableView.backgroundColor = [UIColor whiteColor];
    self.xlTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/**
 请求网络数据 不添加没有内容的数据
 */
-(void)requestData{
    __weak typeof(self) weakSelf = self;
    NSDictionary *dict = @{
                           @"jwid" : JWid,
                           @"jwpassword" : JWpassword,
                           @"type" : @"1",
                           @"eid" : self.questionID,
                           @"star" : self.star
                           };
    [[AFNetworkTool shareManager]postJSONWithUrl:JW_whichevaluate parmas:dict successData:^(id json) {
      //  NSLog(@"%@", json);
        NSArray * arr = json[@"list"];
        for (int i = 0; i<arr.count; i++) {
            QuestionsModel * model = [QuestionsModel yy_modelWithJSON:arr[i]];
            if ([model.content isEqualToString:@""]) {
               // NSLog(@"没数据");
            }else{
                [weakSelf.questionArray addObject:model];
            }
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            [weakSelf.xlTableView reloadData];
        });
    } failure:^(NSError *error) {
        
    }];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.questionArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *SimpleTableIdentifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
    if (cell ==nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier: SimpleTableIdentifier];
        cell.detailTextLabel.numberOfLines = 0;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    QuestionsModel * model = self.questionArray[indexPath.row];
    cell.textLabel.text = model.sname;
    cell.detailTextLabel.text = model.content;
    return cell;
}

- (NSMutableArray *)questionArray {
    if(!_questionArray) {
        _questionArray = [NSMutableArray array];
    }
    return _questionArray;
}
@end

